#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <map>
#include <climits>
#include <unordered_map>
using namespace std;

bool check(vector<int> &list2,unordered_map<int,int> &mp){
    for(int x:list2){
        if(!mp.count(x)||(mp.count(x)&&mp[x]<=0)){
            return false;
        }
    }
    return true;
}


vector<int> unique_list(vector<int> &list1,vector<int> &list2){
    int len1=list1.size(),len2=list2.size();
    unordered_map<int,int> mp;
    vector<int> mark(len1,0),ans;
    int l=0,r=0;
    mp[list1[l]]++;
    do{
        mp[list1[++r]]++;
        if(r-l+1==len2){
            if(check(list2,mp)){
                for(int j=l;j<=r;j++){
                    mark[j]=1;
                }
            }
            mp[list1[l++]]--;
        }
    }while(l<r&&r<len1);

    for(int i=0;i<len1;i++){
        if(!mark[i]){
            ans.push_back(list1[i]);
        }
    }

    return ans;
}

int main(){
    vector<int> v={0,5,6,7,1,2,3,4,5,6,7,8},v2={5,6,7};

    auto ans=unique_list(v,v2);
    for(auto x : ans){
        cout << x << " ";
    }cout <<endl;

    return 0;
}